package edu.ucollege.android;

import edu.ucollege.android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.content.*;
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        GridView gridView = (GridView) findViewById(R.id.grid_view);
 
        // Instance of ImageAdapter Class
        gridView.setAdapter(new ImageAdapter(this));


        gridView.setOnItemClickListener(new OnItemClickListener() {
        	public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        		//send image id
        		Intent i = null;
        		switch(position){
        		case 0:	i = new Intent(getApplicationContext(), CafeActivity.class);
        				break;
        		case 1: i = new Intent(getApplicationContext(), BibleActivity.class);
        				break;
        		case 2: i = new Intent(getApplicationContext(), ClubActivity.class);
    					break;
        		case 3: i = new Intent(getApplicationContext(), ContactsActivity.class);
    					break;
        		case 4: i = new Intent(getApplicationContext(), PlaceActivity.class);
    					break;
        		case 5: i = new Intent(getApplicationContext(), MoodleActivity.class);
    					break;
        		case 6: i = new Intent(getApplicationContext(), ClockTowerActivity.class);
    					break;
        		case 7: i = new Intent(getApplicationContext(), GoodMorningActivity.class);
    					break;
        		case 8: i = new Intent(getApplicationContext(), CodeActivity.class);
        				break;
				default: i = null;
						break;
        		}
        		 
        		//passing array index
        		i.putExtra("id", position);
        		startActivity(i);
        	}
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}


